<%--
  Created by IntelliJ IDEA.
  User: SXT
  Date: 2020/6/30
  Time: 15:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员管理页面</title>
    <base href="<%=request.getContextPath()+"/"%>">
    <%--引入easyui主题的css样式--%>
    <link rel="stylesheet" href="easyui/themes/default/easyui.css">
    <%--引入easyui中图标集的css样式--%>
    <link rel="stylesheet" href="easyui/themes/icon.css">
    <%--引入demo.css--%>
    <link rel="stylesheet" href="easyui/themes/demo.css">
    <%--引入jq中js文件  注意：先引入jq中js在引入easyui中js--%>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <%--引入easyui中核心js文件--%>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>

    <script type="text/javascript">

        $(function () {
            $('#dg').datagrid({
                url:'admin/findAll',
                pagination:true,//设置分页栏展示
                rownumbers:true,//设置行号显示
                pageSize:5,//设置size的初始大小
                pageList:[5,10,15,20],// 设置每一页显示条数列表
                toolbar:"#tb",
                columns:[[
                    {field:'aid',title:'管理员编号',width:100,align:'center'},
                    {field:'aname',title:'管理员名称',width:100,align:'center'},
                    {field:'apwd',title:'管理员密码',width:100,align:'center'},
                    {field:'aphone',title:'管理员手机号',width:100,align:'center'}
                ]]
            });
        })
        //添加管理员的实现
        function newAdmin() {
            //打开数据网格
            $("#admin_dlg").dialog("open");
            //清空表单数据
            $("#admin_fm").form("clear")


        }
        function saveAdmin() {
            var val=$("#admin_fm").serialize();
            $.post("admin/insertAdmin",val,function (result) {
                if(result>0){
                    //关闭当前对话框
                    $("#admin_dlg").dialog("close");
                    //重新加载数据网格
                    $("#dg").datagrid("reload");
                }else {
                    $.messager.alert("提示","添加失败","error");
                }

            })
            
        }


    </script>
</head>
<body>

<div style="width: 800px;height: 600px" class="easyui-panel" title="管理员管理">
    <div style="width: 750px;height: 400px;border: 0px solid red;margin: 0px auto;margin-top: 30px">

        <table id="dg" style="width: 750px;height: 400px"></table>

        <%--工具栏设置--%>
        <div id="tb">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newAdmin()">添加管理员</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editCompany()">编辑管理员</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="chsList()">删除管理员</a>
        </div>
    </div>
</div>

<div id="admin_dlg" class="easyui-dialog" style="width:400px" data-options="closed:true,modal:true,border:'thin',buttons:'#admin_dlg-buttons'">
    <form id="admin_fm" method="post" novalidate style="margin:0;padding:20px 50px">
        <h3>Company Information</h3>
        <div style="margin-bottom:10px">
            <input name="aname" class="easyui-textbox" required="true" label="管理员名称:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <input name="apwd" class="easyui-textbox" required="true" label="管理员密码:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <input name="aphone" class="easyui-textbox" required="true" label="管理员电话:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <input name="starttime" class="easyui-textbox" required="true" label="注册时间:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <input class="easyui-combobox" name="rid" style="width:100%;" data-options="
                    url:'role/findAll2',
                    method:'get',
                    valueField:'rid',
                    textField:'rname',
                    panelHeight:'auto',
                    label: '角色选择:',
                    labelPosition: 'left'">

        </div>
    </form>
</div>
<div id="admin_dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveAdmin()" style="width:90px">Save</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
</div>
</body>
</html>
